package org.millioncall.yueyoga.admin.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.millioncall.yueyoga.admin.dao.BaseDao;
import org.millioncall.yueyoga.admin.dao.CheduleDetailsDAO;
import org.millioncall.yueyoga.admin.model.CheduleDetails;
import org.millioncall.yueyoga.admin.model.ClassScheduleModel;

public class CheduleDetailsDAOImpl extends BaseDao implements CheduleDetailsDAO {

	@Override
	public List<CheduleDetails> findcheduleDetailsByCalssId(Map<String, Object> maps) {
		return this.getPagableSqlSessionTemplate().selectList("findCheduleDetailsByMap", maps);
	}

	@Override
	public List<ClassScheduleModel> findClsScheduleByClsId(Integer classId, String curDate) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("classId", classId.toString());
		map.put("cheduleTime", curDate);
		return this.getPagableSqlSessionTemplate().selectList("findClsSchedulesByClsId", map);
	}

	@Override
	public boolean addCheduleDetail(CheduleDetails details) {
		return this.getPagableSqlSessionTemplate().insert("addCheduleDetail", details) > 0;
	}

	@Override
	public CheduleDetails findCheduleDetailsByCdts(String kcxh, String scheduleId, String curDate) {
		Map<String, String> map = new HashMap<String, String>();
		map.put("scheduleId", scheduleId);
		map.put("curDate", curDate);
		map.put("kcxh", kcxh);
		return this.getPagableSqlSessionTemplate().selectOne("findCheduleDetailsByCdts", map);
	}

	@Override
	public int updateCheduleDetails(CheduleDetails cd) {
		return this.getPagableSqlSessionTemplate().update("updateCheduleDetails", cd);
	}

	@Override
	public List<CheduleDetails> findAllCheduleDetailsByMap(Map<String, Object> map) {
		return this.getPagableSqlSessionTemplate().selectList("findAllCheduleDetailsByMap", map);
	}

	@Override
	public List<ClassScheduleModel> findScheduleDetailListByCdts(Map<String, Object> map) {
		return this.getPagableSqlSessionTemplate().selectList("findScheduleDetailListByCdts", map);
	}

	@Override
	public List<ClassScheduleModel> findPersonScheduleListByCdts(Map<String, Object> map) {
		return this.getPagableSqlSessionTemplate().selectList(
				"findPersonScheduleListByCdts", map);
	}

	@Override
	public int updateReserveCount(Map<String, Object> map) {
		return this.getPagableSqlSessionTemplate().update("updateReserveCount", map);
	}

	@Override
	public int updateScheduleOver(Map<String, Object> map) {
		return this.getPagableSqlSessionTemplate().update("updateScheduleOver", map);
	}

	@Override
	public CheduleDetails findCheduleDetailById(Map<String, Object> map) {
		return this.getPagableSqlSessionTemplate().selectOne("findCheduleDetailById", map);
	}

	@Override
	public Boolean deleteAllCheduleByMap(Map<String, Object> map) {
		return this.getPagableSqlSessionTemplate().update("deleteAllCheduleByMap", map)>0;
	}
}
